<template>
  <div>
    <div v-if="show" class="cus">
      <div class="cus_box">
        <div class="title">
          <span>电池详情</span
          ><i @click="show = false" class="el-icon-close"></i>
        </div>
        <div class="content">
          <ul>
            <li>
              <span>电池ID:</span><span>{{ battery_info.batteryNo }}</span>
            </li>
            <li>
              <span>总电压：</span><span>{{ battery_info.voltage / 100 }}</span>
            </li>
            <li>
              <span>电池状态：</span
              ><span>{{
                battery_info.status == 0
                  ? "充电中"
                  : battery_info.status == 1
                  ? "租用中"
                  : battery_info.status == 2
                  ? "闲置"
                  : "--"
              }}</span>
            </li>
            <li>
              <span>电池温度：</span><span>{{ battery_info.temperature }}</span>
            </li>
            <li>
              <span>电池容量：</span><span>{{ battery_info.ah / 100 }}</span>
            </li>
            <li>
              <span>剩余电量：</span><span>{{ battery_info.remainSoc }}%</span>
            </li>
            <li>
              <span>电池位置：</span><span>{{ currentAddress }}</span>
            </li>
          </ul>
          <div>
            <div
              id="searchResultPanel"
              style="
                border: 1px solid #c0c0c0;
                width: 150px;
                height: auto;
                display: none;
              "
            ></div>
            <div id="l-map"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import getAddress from "../../js/map";
export default {
  name: "battery_details",
  data() {
    return {
      baiduMap: null,
      show: false,
      battery_info: {},
      currentAddress: "",
    };
  },
  watch: {
    show: function (state) {
      if (!state) {
        this.currentAddress = "";
      }
    },
  },
  created() {},

  mounted() {},
  methods: {
    async map() {
      if (Number(this.battery_info.lng) && Number(this.battery_info.lat)) {
        let res = await getAddress(
          Number(this.battery_info.lng),
          Number(this.battery_info.lat)
        ); // 113.304049, 22.977932
        this.currentAddress = res;
      } else {
        this.currentAddress = "暂无电池位置";
      }
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  ul {
    li {
      line-height: 30px;
    }
  }
}

#l-map {
  height: 250px;
  width: 100%;
}
</style>
